<div class="modal-dialog">
    <div class="modal-content">
        <form role="form" action="{:U('purview/action_edit')}" method="post" id="addForm">
        	<input type="hidden" name="id" value="{$id}" />
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">编辑操作</h4>
            </div>
            <div class="modal-body">

                <div class="form-group">
                    <label for="name">操作名称</label>
                    <input type="name" class="form-control" id="name" name="name" value="{$name}">
                </div>
                <div class="form-group">
                    <label for="mid">所属模块</label>
                   <select name="mid" id="mid" class="form-control">
                   		<volist name="modules" id="module">
                   			<optgroup label="{$module.name}">
                   			<volist name="module.child" id="val">
                   				<option value="{$val.id}" <eq name="val.id" value="$mid">selected</eq>  >{$val.name}</option>
               				</volist>
               				</optgroup>
               			</volist>
                   	
                   </select>
                </div>
                
                <div class="form-group">
                    <label for="menus">操作</label>
                   <select name="purview[]" id="purview" multiple="multiple" style="width: 100%;">
                   		<volist name="actions" id="action">
                   			<optgroup label="{$key}">
                   				<php>$ctl = $key</php>
                   				<volist name="action" id="val" key="n">
                   					<php>$act = $ctl.'.'.$val;
                   					$act2 = $ctl.'->'.$val
                   					</php>
                   					<option value="{$act}" <in name="act" value="$purview">selected</in>>{$act2}</option>
                   				</volist>
                   				
                   			</optgroup>
                   			
                   		</volist>
                   </select>
                </div>
                

            </div>
            <div class="modal-footer">
                <button  type="submit" class="btn btn-danger">保存</button>
            </div>
        </form>
    </div>
    <script type="text/javascript">
    $("#addForm").bootstrapValidator({              
                    excluded: [':disabled'],
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    submitHandler: function (validator, form, submitButton) {
                        validator.defaultSubmit();
                    },
                    fields: {
                        name: {
                            validators: {
                                notEmpty: {
                                    message: '操作名称不能为空'
                                }
                            }
                        },
                        'purview[]': {
                            validators: {
                                notEmpty: {
                                    message: '操作方法不能为空'
                                }
                            }
                        }
                    }
                });
    
    	$("#purview").select2({
			placeholder: "关联操作",
			allowClear: true,
		});
    </script>